//
//  OALabel.m
//  OASDK_Works
//
//  Created by ChenJie on 4/7/20.
//  Copyright © 2020 Mist. All rights reserved.
//

#import "OALabel.h"

@interface OALabel ()

@end

@implementation OALabel

#pragma mark - Lifecycle methods

- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
    }
    return self;
}

- (void)willMoveToSuperview:(UIView *)newSuperview {
    [super willMoveToSuperview:newSuperview];
}

- (void)didMoveToSuperview {
    [super didMoveToSuperview];
}

- (void)willMoveToWindow:(UIWindow *)newWindow {
    [super willMoveToWindow:newWindow];
}

- (void)didMoveToWindow {
    [super didMoveToWindow];
}

- (void)layoutSubviews {
    [super layoutSubviews];
    
    //
}

- (void)drawTextInRect:(CGRect)rect {
    return [super drawTextInRect:UIEdgeInsetsInsetRect(rect, self.contentInsets)];
}

#pragma mark - Public methods

- (void)resizeHeightToFitText {
    CGRect frame = [self bounds];
    CGFloat textWidth = frame.size.width - (self.contentInsets.left + self.contentInsets.right);
    CGSize newSize = [self.text boundingRectWithSize:CGSizeMake(textWidth, 1000000)
                                             options:NSStringDrawingUsesLineFragmentOrigin
                                          attributes:@{NSFontAttributeName: self.font}
                                             context:nil].size;
    frame.size.height = newSize.height + self.contentInsets.top + self.contentInsets.bottom;
    self.frame = CGRectMake(self.frame.origin.x, self.frame.origin.y, frame.size.width, frame.size.height);
}

#pragma mark - Private methods



#pragma mark - Event response methods



#pragma mark - Delegate methods



#pragma mark - Setter



#pragma mark - Getter



#pragma mark - Memory management methods

- (void)dealloc {
}

@end
